package DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class DBFactory {
	public static Connection createConnection(String type) {
		//静态工长，对数据库的连接,针对不同数据库
		Connection con=null;
		if(type.equals("mysql")) {
			try {
				con=DriverManager.getConnection("jdbc:mysql://localhost/myclassdb?characterEncoding=utf8&serverTimezone=GMT%2B8", "root", "");
			} catch (SQLException e) {
				// TODO Auto-generated catch block
//				e.printStackTrace();
				JOptionPane.showMessageDialog(null, "数据库连接错误");
			}
		}else if(type.equals("sqlsever")){
			
		}
		
		return con;
	}

}
